<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all"/>
</head>
<body>
<div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div>
            <header style="height: 100%">
                <div align="left">
                    <table style="width: 100%">
                        <tr>
                            <td>
                                <form class="form-inline" onsubmit="return false">
                                    <div class="form-group">
                                        订单id：
                                        <input id="orderId" type="text" class="form-control" placeholder="orderId">
                                        用户id：
                                        <input id="userId" type="text" class="form-control" placeholder="userId">
                                        流水类型：
                                        <select id="state" name="state" class="form-control">
                                            <option value="">全部</option>
                                            <option value="0">支出</option>
                                            <option value="1">收益</option>
                                        </select>
                                        订单状态：
                                        <select id="settlement" name="settlement" class="form-control">
                                            <option value="">全部</option>
                                            <option value="0">未结算</option>
                                            <option value="1">已结算</option>
                                            <option value="3">申请退款</option>
                                            <option value="2">退款</option>
                                        </select>
                                        <button id="searchBt" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe615;</i>搜索
                                        </button>
                                    </div>
                                </form>
                            </td>
                            <!--<td align="right">-->
                            <!--<button class="layui-btn layui-btn-sm" onclick="location.href='addMfflProfit.html'">-->
                            <!--<i class="layui-icon">&#xe608;</i> 添加-->
                            <!--</button>-->
                            <!--</td>-->
                        </tr>
                    </table>
                </div>
            </header>

            <div>
                <div class="widget-body no-padding">
                    <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                        <thead>
                        <tr>
                        </tr>
                        <tr>
                            <th>id</th>
                            <th>订单id</th>
                            <th>用户id</th>
                            <th style="width: 70px;">昵称</th>
                            <th>服务名称</th>
                            <th>流水类型</th>
                            <th>金额</th>
                            <th>订单状态</th>
                            <th>创建时间</th>
                            <th>结算时间</th>
                            <th>扣点比例</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/my/permission.js"></script>
<script type="text/javascript">
    var pers = checkPermission();

    var example;

    function init() {
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide": true,
                "language": {
                    "url": "/js/plugin/datatables/Chinese.lang"
                },
                "ajax": {
                    "url": "/mfflProfits",
                    "type": "get",
                    "data": function (d) {
                        d.orderId = $("#orderId").val();
                        d.userId = $("#userId").val();
                        d.state = $("#state").val();
                        d.settlement = $("#settlement").val();
                    }
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                    {"data": "id", "defaultContent": ""},
                    {"data": "orderId", "defaultContent": ""},
                    {"data": "userId", "defaultContent": ""},
                    {"data": "nickname", "defaultContent": ""},
                    {"data": "servciceName", "defaultContent": ""},
                    {
                        "data": "state",
                        "defaultContent": "",
                        "render": function (data, type, row) {
                            var flag = row['state'];
                            if (flag == '0') {
                                return "支出";
                            } else if (flag == '1') {
                                return "收益";
                            }
                        }
                    },
                    {"data": "money", "defaultContent": ""},
                    {
                        "data": "settlement",
                        "defaultContent": "",
                        "render": function (data, type, row) {
                            var flag = row['settlement'];
                            if (flag == '0') {
                                return "未结算";
                            } else if (flag == '1') {
                                return "已结算";
                            } else if (flag == '2') {
                                return "退款";
                            } else if (flag == '3') {
                                return "申请退款";
                            }
                        }
                    },
                    {"data": "createTime", "defaultContent": ""},
                    {"data": "settlementTime", "defaultContent": ""},
                    {"data": "deduction", "defaultContent": ""},
                ],
                "order": [[0, "asc"]]
            });
    }

    layui.use('layer', function () {
        var layer = layui.layer;
    });

    function del(id) {
        layer.confirm('确定要删除吗？', {
            btn: ['确定', '取消']
        }, function () {
            $.ajax({
                type: 'delete',
                url: '/mfflProfits/' + id,
                success: function (data) {
                    example.ajax.reload();
                    layer.msg("删除成功");
                }
            });

            layer.close(1);
        });
    }

    $("#searchBt").click(function () {
        example.ajax.reload();
    });

    init();
</script>
